# -*- coding: utf-8 -*-
import scrapy,time,json
import hashlib

class RenrenspiderSpider(scrapy.Spider):
    name = 'renrenSpider'
    allowed_domains = ['http://www.renren.com/']
    #start_urls = ['http://www.renren.com']

    def start_requests(self):
    	url = 'http://www.renren.com/ajaxLogin/login?1=1&uniqueTimestamp='+str(time.time())
    	# email = input('请输入登录账户：')
    	# password = input('请输入登录密码：')
    	# md5 = hashlib.md5()
    	# md5.update(password.encode(encoding='utf-8'))
    	headers = {
    		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36',
    		'Content-Type': 'application/x-www-form-urlencoded'
    	}
    	data ={
    		'email':'319316515@qq.com',
    		'password' : '3b419f5ea7a28628fa76e33e50c41b706660f5184c8d5a52f54b37b3217c2c93',
    		'rkey' : '188e3816feae51e6b1ece7066ef7e03b'
    	}
    	yield scrapy.FormRequest(url,formdata = data,headers = headers,callback =self.parse)

    def parse(self, response):
    	print('--|'*30)
    	print('登录结果：',end='')
    	print(response.text)
    	print('--|'*30)